/**
 * 商品Grid 组件
 * 
 */
define(function(require, exports, module) {
			require("/ecp/component/ecp/common/gridproduct/src/css/GridProduct.css");
			require("/ecp/component/ecp/common/gridproduct/src/css/product_center.css");
			
			
			var Grid = require("/ecpub/component/webpub/common/grid/src/js/Grid");
			var handler = require("/ecpub/component/webpub/tools/handlebars").Handlebars;
			
			var tpl_list = require("/ecp/component/ecp/common/gridproduct/src/js/GridProductList.tpl").html;
			var tpl_thumb = require("/ecp/component/ecp/common/gridproduct/src/js/GridProductThumb.tpl").html;
			
			
			
			var tpl = "";
			tpl = tpl_list;

			var GridProduct = function(option) {
				option.initHead = function() {

				};
				option.initBody = function(records) {
					var template = handler.compile(tpl);
					return template(records);
				};
				//表格创建后添加库存和精度限制
				option.afterGeneBody = function(){
				};
				var grid = new Grid(option);
				/**
				 * 缩略图显示
				 */
				var thumb = function(){
					tpl = tpl_thumb;
					grid.refresh();
				};
				var list = function(){
					tpl = tpl_list;
					grid.refresh();
				};
				/**
				 * 切换展示方式
				 */
				$("body").delegate(".ET_switchView","click",function(){
					if(tpl == tpl_thumb){
						list();
					}else{
						thumb();
					}
					return false;
				});				
				return grid;
			};
			module.exports = GridProduct;
			
			/**
			 * javascript:viewProductDetail(\'' + item.cproductid + '\',\'' + item.vhtmurl + '\');
			 * 图片点击
			 * 商品名称点击
			 * width="100" height="80" 图片样式
			 */
			
		});